<?php
/**
 * Created by PhpStorm.
 * User: guokunsheng
 * Date: 2018/6/6
 * Time: 16:16
 */
namespace app\api\controller\v4;
use app\api\controller\v2\Auth;
use app\common\lib\exception\ApiException;
use app\common\model\Article as ArticleModel;

/**
 * @title 文章相关接口
 * @desc 查看文章详情<br/>按页码获取文章列表，每页十条<br/>
 * @url /api/v2/article
 * @version 2.0.0
 * Class Article
 * @package app\api\controller\v2
 */
class Article extends Auth
{
    protected $restActionList = ['index','read'];

    /**
     * @title 获取文章列表
     * @method GET
     * @return array|\think\response\Json
     * @throws ApiException
     */
    public function index()
    {
        if (!request()->isGet()) {
            return show(config('code.error'), '未知操作', '', 403);
        }

        $map = [
            'page' => input('get.page/d', 1),
            'cid' => input('get.cid/d'),
            'uid' => $this->user['id'],
            'uc_id' => $this->user['uc_id'],
        ];

        $data = (new ArticleModel())->getArticleList($map);

        return show(config('code.success'), '加载成功', $data);
    }
}